package com.qf.business.redevnlopes.core.listener;

import com.ken.event.action.apply.consumer.IKenEventHandler;
import com.ken.event.action.apply.consumer.KenEvent;
import com.ken.event.standard.entity.KenMessage;
import com.qf.business.redevnlopes.core.service.RedEnvelopesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * author Ken
 * create_time 2022/9/29
 */
@KenEvent("red-send")
@Slf4j
public class RedSendDelayEventHandler implements IKenEventHandler<Integer> {

    @Autowired
    private RedEnvelopesService redEnvelopesService;

    @Override
    public void eventHandler(Integer redId, KenMessage kenMessage) {
        try {
            log.debug("[red timeout] 红包到期的消息 - {}", redId);
            redEnvelopesService.redBack(redId);
        } catch (Throwable t) {
            throw new RuntimeException("随便抛出的异常!!!");
        }
    }
}
